<?php

namespace App\Dao;

use SimpleSoftwareIO\QrCode\Facades\QrCode;

class CommonDao extends BaseDao
{

    public static function data_s(array $params = []): array
    {
        $start_yue = strtotime(date('Y-m-01'));
        return [
            'order_now_month_price'=>OlisOrderDao::builder_query([
                'user_id'=>$params['user_id'],
                'status'=>1
            ])->where('created_at','>=',$start_yue)->sum('price'),
            'order_all_price'=>OlisOrderDao::builder_query([
                'user_id'=>$params['user_id'],
                'status'=>1
            ])->sum('price'),
        ];
    }

    public static function get_hexiao_code($params = []){
        $code_name = 'hexiao_code_'.$params['user_id'].'.svg';
        QrCode::size(200)->generate($params['user_id'], public_path($code_name));
        return 'https://wyxny.19w.top/'.$code_name;
    }

    //核销
    public static function hexiao(array $params)
    {

    }
}
